from api.base_api import BaseApi


class LoginApi(BaseApi):
    _yaml_path = "../datas/request_data/login_api.yaml"

    def login(self, env: str, user_name: str, pass_word: str):
        """
        新版排班登录接口
        :param env:环境
        :param user_name: 用户名
        :param pass_word: 密码
        :return: ResponseBody
        """
        self._params['host'] = self.config_read('host', env)
        pass_word = self.crypt(pass_word)
        self._params['user_name'] = user_name
        self._params['password'] = pass_word
        data = self.yaml_read(self._yaml_path, 'login')
        return self.send(data)

    def logout(self, env, token):
        """
        登出接口
        :return: ResponseBody
        """
        self._params['host'] = self.config_read('host', env)
        self._params['token'] = token
        data = self.yaml_read(self._yaml_path, 'logout')
        return self.send(data)
